<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
    <title>书籍列表</title>
    <style>
        table {
            width: 100%;
            border-collapse: collapse;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
            overflow: hidden;
        }
        th, td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #007bff;
            color: white;
            font-weight: bold;
        }
        tr:hover {
            background-color: #f5f5f5;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        button {
            padding: 6px 12px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        button:hover {
            opacity: 0.9;
        }
        a {
            text-decoration: none;
        }
    </style>
</head>
<body>
    <h2>书籍列表</h2>
    
    <!-- 添加书籍按钮 -->
    <a href="/books/addbook" style="margin-bottom: 20px; display: inline-block;">
        <button>添加书籍</button>
    </a>

    <table>
        <thead>
            <tr>
                <th>ID</th>
                <th>书名</th>
                <th>作者</th>
                <th>出版社</th>
                <th>出版日期</th>
                <th>价格</th>
                <th>操作</th> <!-- 新增操作列 -->
            </tr>
        </thead>
        <tbody>
            <c:forEach items="${books}" var="book">
                <tr>
                    <td>${book.bookid}</td>
                    <td>${book.bookname}</td>
                    <td>${book.author}</td>
                    <td>${book.publisher}</td>
                    <td>${book.publishDate}</td>
                    <td>${book.price}</td>
                    <td>
                        <!-- 更新按钮 -->
                        <a href="/books/update/${book.bookid}">
                            <button style="background-color: #4CAF50; color: white;">更新</button>
                        </a>
                        <!-- 删除按钮 -->
                        <a href="/books/delete/${book.bookid}" onclick="return confirm('确定要删除这本书吗？')">
                            <button style="background-color: #f44336; color: white;">删除</button>
                        </a>
                    </td>
                </tr>
            </c:forEach>
        </tbody>
    </table>
</body>
</html>
